package com.jason.apps.dashboard;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.view.SubMenu;
import com.apps.realtyportal.HomeActivity;
import com.apps.realtyportal.R;

public class DashBoard extends SherlockFragmentActivity {

	private ActionBar actionbar;
	private static final int LOGOUT = 1;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.dashboard_layout);
		actionbar = getSupportActionBar();
		actionbar.setDisplayHomeAsUpEnabled(true);
		actionbar.setDisplayShowTitleEnabled(false);
		actionbar.setLogo(R.drawable.logo3);

	}

	@Override
	public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) {
//		 menu.add(0, LOGOUT, 0, "Logout")
//		 .setIcon(R.drawable.ic_action_overflow)
//		 .setShowAsAction(
//		 MenuItem.SHOW_AS_ACTION_IF_ROOM);
		SubMenu subMenu = menu.addSubMenu("Options");

		//subMenu.add("Logout").setIcon(R.drawable.logouticon);
		//subMenu.add("Go to Profile").setIcon(R.drawable.profile1);
		
		subMenu.add(0, 10, Menu.NONE, "Logout").setIcon(R.drawable.logouticon);
        //subMenu.add(0, 15, Menu.NONE, "Go to Profile").setIcon(R.drawable.profile);
        
        
		MenuItem subMenu1Item = subMenu.getItem();
		subMenu1Item.setIcon(R.drawable.ic_action_overflow);
		subMenu1Item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
		


		return super.onCreateOptionsMenu(menu);

	}

	public void ManageAccount(View view) {
		// Launching News Feed Screen
		Intent i = new Intent(getApplicationContext(), ManageAgent.class);
		startActivity(i);
	}

	public void ManageProperty(View view) {
		// Launching News Feed Screen
		Intent i = new Intent(getApplicationContext(), ManageProperty.class);
		startActivity(i);
	}

	public void Report(View view) {
		// Launching News Feed Screen
		Intent i = new Intent(getApplicationContext(), Reports.class);
		startActivity(i);
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		super.onOptionsItemSelected(item);
		switch (item.getItemId()) {
		case android.R.id.home:
			Intent intent = new Intent(this, HomeActivity.class);
			intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
			startActivity(intent);

		case 10:

			HomeActivity.islogin = false;
			finish();
			startActivity(new Intent(this, HomeActivity.class));
			
		
			

		}

		return super.onOptionsItemSelected(item);
	}

}
